package com.cyy.service;


import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.ConfigurableEnvironment;

import java.net.InetAddress;
import java.net.UnknownHostException;

@SpringBootApplication
@ComponentScan({"com.cyy.common", "com.cyy.system","com.cyy.api"})
@MapperScan("com.cyy.common.mapper")
public class CBlogApplication {

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(CBlogApplication.class, args);

        ConfigurableEnvironment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");
        String swaggerEnable = env.getProperty("springdoc.swagger-ui.enabled");
        String knife4jEnable = env.getProperty("springdoc.api-docs.enabled");
        String swaggerPath = env.getProperty("springdoc.swagger-ui.path");
        String knife4jPath = "/doc.html";
        if (("true").equals(swaggerEnable)) {
            System.out.println("Swagger: http://" + ip + ":" + port + path + swaggerPath);
        }
        if (("true").equals(knife4jEnable)) {
            System.out.println("Knife4j: http://" + ip + ":" + port + path + knife4jPath);
        }
    }
}
